from django.db import models

# Create your models here.


class User(models.Model):
    id = models.AutoField(primary_key=True)
    name=  models.CharField(max_length=256)  
    phone=  models.CharField(max_length=256)
    openid=  models.CharField(max_length=256)
    session_key = models.CharField(max_length=256)
    # parent_id= models.IntegerField()
    # is_dir= models.IntegerField()
    # order_num= models.IntegerField()
    created_at = models.DateTimeField(auto_now_add=True)
    class Meta:
        db_table = 'user'

class Order(models.Model):
    id = models.AutoField(primary_key=True)
    out_trade_no=  models.CharField(max_length=256)
    report_id = models.IntegerField()
    stat = models.IntegerField()
    is_del = models.IntegerField()
    transaction_id = models.CharField(max_length=256)
    trade_type= models.CharField(max_length=256)
    out_trade_no = models.CharField(max_length=256)
    trade_state = models.CharField(max_length=256)
    success_time = models.CharField(max_length=256)
    amount = models.IntegerField()
    # is_dir= models.IntegerField()
    # order_num= models.IntegerField()
    created_at = models.DateTimeField(auto_now_add=True)
    class Meta:
        db_table = 'order'

class Report(models.Model):
    id = models.AutoField(primary_key=True)
    user_id =  models.IntegerField()
    type =  models.IntegerField()
    imgpath =  models.CharField(max_length=256)
    alg_out =  models.TextField()  
    explain =  models.TextField()

    created_at = models.DateTimeField(auto_now_add=True)
    class Meta:
        db_table = 'report'

class ReportOrder(models.Model):
    id = models.AutoField(primary_key=True)
    user_id =  models.IntegerField()
    type =  models.IntegerField()
    imgpath =  models.CharField(max_length=256)
    alg_out =  models.TextField()  
    explain =  models.TextField()

    created_at = models.DateTimeField(auto_now_add=True)
    stat = models.IntegerField()
    trade_type = models.CharField(max_length=256)
    out_trade_no = models.CharField(max_length=256)
    class Meta:
        db_table = 'v_report_order'